package org.alerve.android.resourcebuilder;

import org.alerve.android.resourcebuilder.modules.ActivityModule;
import org.alerve.android.resourcebuilder.modules.DialogModule;
import org.alerve.android.resourcebuilder.modules.ViewGroupModule;
import org.alerve.android.resourcebuilder.AbstractDirector.Modules;

/**
 * 
 * Implementation of {@link AbstractDirector} that inflates and populates
 * certain types of objects.
 * 
 * @author pabs87@gmail.com
 * 
 */
@Modules({ActivityModule.class, ViewGroupModule.class, DialogModule.class})
public class ModuleDirector extends AbstractDirector<IModule<?>> {

	private static ModuleDirector instance;

	public static ModuleDirector getInstance() {
		if (instance == null) {
			instance = new ModuleDirector();
		}
		return instance;
	}

	@SuppressWarnings("unchecked")
	public <Type> void build(Type subject) {
		IModule<Type> builder = (IModule<Type>) getModule(subject.getClass());
		builder.build(subject);
	}

}
